/*
 * @lc app=leetcode id=167 lang=cpp
 *
 * [167] Two Sum II - Input array is sorted
 */
class Solution {
public:
    vector<int> twoSum(vector<int>& numbers, int target) {
        int len = numbers.size();
        if (len < 2) {
            return {};
        }

        int sum;
        int i = 0;
        int j = len-1;
        while (i < j) {
            sum = numbers[i] + numbers[j]; 
            if (sum == target) {
                return {i+1, j+1};
            } else if (sum > target) {
                j--;
            } else {
                i++;
            }
        }

        return {};
        
    }
};

